package com.etoak.init;

import com.etoak.config.MvcConfig;
import com.etoak.config.RootConfig;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import javax.servlet.Filter;

/**
 * @program: activemq-SpringMVC
 * @description: 配置
 * @author: 管浩杰
 * @create: 2021-03-17 09:32
 **/

public class MvcInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    /* Spring Root 容器 */

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class<?>[]{RootConfig.class};
    }

    /* SpringMvc 容器 */

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class<?>[]{MvcConfig.class};
    }


    /* dispatcher 前端拦截器 */
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    /* 过滤编码 */

    @Override
    protected Filter[] getServletFilters() {
        CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
        encodingFilter.setEncoding("UTF-8");
        return new Filter[]{encodingFilter};
    }
}
